package main

import (
	"strconv"
	"strings"
)

func main() {
	print(strings.Join(twoSum([]int{2, 11, 7, 15}, 9), ","))
}

// 给定一个整数数组 nums 和一个目标值 target，请你在该数组中找出和为目标值的那 两个 整数，并返回他们的数组下标。
// nums: 给定数组
// target: 给定和
func twoSum(nums []int, target int) []string {
	for i, v := range nums {
		var diff = target - v
		for j, v2 := range nums {
			if v != v2 && v2 == diff {
				return []string{strconv.Itoa(i), strconv.Itoa(j)}
			}
		}
	}
	return []string{}
}
